import numpy as np
import httplib2
import os
import uuid
from PIL import Image, ImageEnhance, ImageFilter, ImageDraw
import captcha_1 as c1


im = Image.open("D:/box/captcha2/src/e4b36fba-3efd-4af3-bf49-5386593388bf.png")
#im = Image.open("D:/box/captcha2/src/b7353de4-ad2c-4b85-9d3a-08159e9627d1.png")
enhancer = ImageEnhance.Contrast(im)
#去除干扰
im = enhancer.enhance(5)
# 去背景色
imgry = im
imgry = im.convert('L')
#imgry = imgry.convert('1')

#clearNoise(imgry,20,2,3)
arr = np.asarray(imgry)

m,n = arr.shape
arr_new = arr>1

imgry.show()

imx = Image.open("d:/box/test.png")





width = 108/6
height = 16
for i in range(6):
    cx = imgry.crop((i*width,0,(i+1)*width,height))
    #cx.show()

#imgry.show()

#x = np.array(dtype=float)